namespace KYO
{
	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.ComponentModel;
	using System.Data;
	using System.Data.SqlClient;
	using System.Text;
	
	
	public class tblNewInfor : Object
	{
		
		#region Static SQL String Memebers
		/// <remarks>This field represents the full SELECT string for the table tblNewInfor, with the WHERE clause.</remarks>
		internal static string _SQL_Select = "SELECT [InforID] FROM [dbo].[tblNewInfor] WHERE [InforID]=@InforID ";
		
		/// <remarks>This field represents the full INSERT INTO string for the table tblNewInfor.</remarks>
		internal static string _SQL_Insert = "INSERT INTO [dbo].[tblNewInfor] ([InforID]) VALUES([InforID]) ";
		
		/// <remarks>This field represents the full UPDATE string for the table tblNewInfor, with the WHERE clause.</remarks>
		internal static string _SQL_Update = "UPDATE [dbo].[tblNewInfor] SET [InforID] = @InforID WHERE [InforID]=@InforID ";
		
		/// <remarks>This field represents the DELETE string for the table tblNewInfor, with the WHERE clause.</remarks>
		internal static string _SQL_Delete = "DELETE FROM [dbo].[tblNewInfor] WHERE [InforID]=@InforID ";
		#endregion
		
		#region Tables Memebers
		/// <remarks>SQL Type:int - </remarks>
		private int _InforID;
		
		[DisplayName("Infor ID")]
		[Category("Primary Key")]
		public int InforID
		{
			get
			{
				try
				{
					return _InforID;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting InforID", err);
				}
			}
			set
			{
				try
				{
					_InforID = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting InforID", err);
				}
			}
		}
		#endregion
		
		#region Related Object Collections
		/// <remarks>Represents the foreign key object</remarks>
		private tblInforInCatagoryCollection _tblInforInCatagoryCollection;
		
		[Description("Represents the foreign key relation. This is an Collection of tblNewInfor.")]
		public tblInforInCatagoryCollection tblInforInCatagoryCollection
		{
			get
			{
				try
				{
					return _tblInforInCatagoryCollection;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting tblInforInCatagoryCollection", err);
				}
			}
			set
			{
				try
				{
					_tblInforInCatagoryCollection = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting tblInforInCatagoryCollection", err);
				}
			}
		}
		#endregion
		
		#region Public Methods
		public void Select(string ConnectionString)
		{
			try
			{
				SqlConnection Conn = new SqlConnection(ConnectionString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = tblNewInfor._SQL_Select;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				SqlDataReader rs = Com.ExecuteReader();
				while(rs.Read())
				{
					AddFromRecordSet(rs);
				}
				rs.Close();
				Conn.Close();
				rs.Dispose();
				Com.Dispose();
				Conn.Dispose();
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Insert(string ConnectionString)
		{
			try
			{
				SqlConnection Conn = new SqlConnection(ConnectionString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = tblNewInfor._SQL_Insert;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Update(string ConnectionString)
		{
			try
			{
				SqlConnection Conn = new SqlConnection(ConnectionString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = tblNewInfor._SQL_Update;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Delete(string ConnectionString)
		{
			try
			{
				SqlConnection Conn = new SqlConnection(ConnectionString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = tblNewInfor._SQL_Delete;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public string[] GetSqlCommandStrings()
		{
			try
			{
				string[] CommStr = new string[4];
				CommStr[0] = "SELECT [InforID] FROM [dbo].[tblNewInfor] WHERE [InforID] = " + _InforID + "";
				CommStr[1] = "INSERT INTO [dbo].[tblNewInfor] ([InforID]) VALUES(" + _InforID + ")";
				CommStr[2] = "UPDATE [dbo].[tblNewInfor] SE WHERE [InforID] = " + _InforID + "";
				CommStr[3] = "DELETE FROM [dbo].[tblNewInfor] WHERE [InforID] = " + _InforID + "";
				return CommStr;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		#endregion
		
		#region Private Methods
		private void AddFromRecordSet(SqlDataReader rs)
		{
			try
			{
				// if value from the recordset, to the InforID field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("InforID")) == false))
				{
					InforID = rs.GetInt32(rs.GetOrdinal("InforID"));
				}
			}
			catch (SqlException sqlExc)
			{
				throw sqlExc;
			}
			catch (Exception Exc)
			{
				throw Exc;
			}
		}
		
		private SqlParameter[] GetSqlParameters()
		{
			List<SqlParameter> SqlParmColl = new List<SqlParameter>();
			try
			{
				SqlParmColl.Add(SqlUtil.AddSqlParm("@InforID", InforID, SqlDbType.Int));
				return SqlParmColl.ToArray();
			}
			catch (Exception Exc)
			{
				throw Exc;
			}
		}
		#endregion
	}
	
	public class tblNewInforCollection : System.Collections.CollectionBase
	{
		
		[Description("Adds a new tblNewInfor to the collection.")]
		public int Add(tblNewInfor item)
		{
			int newindex = List.Add(item);
			return newindex;
		}
		
		[Description("Removes a tblNewInfor from the collection.")]
		public void Remove(tblNewInfor item)
		{
			List.Remove(item);
		}
		
		[Description("Inserts an tblNewInfor into the collection at the specified index.")]
		public void Insert(int index, tblNewInfor item)
		{
			List.Insert(index, item);
		}
		
		[Description("Returns the index value of the tblNewInfor class in the collection.")]
		public int IndexOf(tblNewInfor item)
		{
			return List.IndexOf(item);
		}
		
		[Description("Returns true if the tblNewInfor class is present in the collection.")]
		public bool Contains(tblNewInfor item)
		{
			return List.Contains(item);
		}
	}
	
	public enum tblNewInfor_Fields
	{
		
		InforID,
	}
}
